home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / dviware / beebe / updates / 00mail.12 < prev    next >
Text File  |  1990-10-01  |  34KB  |  726 lines

  1.                 DVI Driver Family Update #12
  2.                         [28-Sep-87]
  3.  
  4. This issue announces Version 2.09, some minor editorial changes,
  5. and fixes to three serious bugs, one of which affects only
  6. dvijep, another only dvialw, and the third, most of the
  7. dot-matrix printer drivers.  The fixes are extracted from the
  8. 00REVHST.TXT file, and I record below everything posted to it
  9. since Version 2.08 (20-Aug-87)
  10.  
  11. I am pleased to announce that the Free Software Foundation GNU
  12. Project C compiler, gcc, now successfully compiles the entire DVI
  13. driver family, both with and without optimization, on the Sun
  14. workstation.  gcc can be built to produce code for Motorola
  15. 68000, 68010, and 68020 CPU's, and for the DEC VAX architecture.
  16. I have installed version 1.11 here, and applied two bug fixes
  17. supplied by Richard Stallman to correct problems in gcc that
  18. showed up during the installation and testing of gcc on the DVI
  19. driver family.  This testing also revealed a bug in the driver
  20. family itself; the fix is documented below.
  21.  
  22. gcc currently runs with the host (Sun or VAX) C library, and
  23. consequently produces code which is calling-sequence compatible
  24. with the native Unix cc compilers.  Presumably a later release of
  25. gcc will include complete run-time libraries, since the goal of
  26. the GNU project is to produce a complete free-standing operating
  27. system that runs on multiple architectures, and is freely
  28. available in source form.
  29.  
  30. gcc's command-line switches are a superset of cc's.  An important
  31. virtue is that specification of the debug switch (-g) does not
  32. nullify the optimization switch (-O), which is one of the great
  33. flaws with the Sun compilers.  Optimization is likely to exhibit
  34. compiler bugs, and it is convenient to be able to track these
  35. down with a source-level debugger that can still find variables
  36. and line numbers, instead of an assembly-level debugger that only
  37. knows about machine addresses.  gcc also is current with the
  38. October 1986 draft of the ANSI C standard, including string
  39. concatenation ("foo" "bar" becomes "foobar"), preprocessor token
  40. squashing ('#define X(n) X##n' results in X(abc) expanding to
  41. Xabc), and function prototype declarations.
  42.  
  43. SRI has just released Version 4 of the TOPS-20 KCC compiler.
  44. Like gcc, this too conforms to the draft ANSI standard, and to
  45. the second edition of S. Harbison and G. Steele, ``C -- A
  46. Reference Manual'', Prentice-Hall (1987).  This version also
  47. finally implements ioctl.h and signal.h, and fills in
  48. miscellaneous other routines from the 4.2BSD Unix library that
  49. were missing in earlier KCC releases
  50.  
  51. The value of early availability of ANSI conformant compilers is
  52. significant, in that it permits more extensive testing of
  53. software portability, and also exposes the code to the more
  54. rigorous cross-checking available via function argument prototype
  55. declarations, a new feature introduced by the ANSI C committee.
  56. Function prototypes were actually borrowed from B. Stroustrup's
  57. C++ language, which is currently implemented as a preprocessor
  58. whose output is fed to the C compiler.
  59.  
  60. C's readiness to automatically coerce values in expressions,
  61. assignments, and function calls is sometimes convenient, but more
  62. often introduces subtle machine dependencies.  The approach I
  63. have rigorously adhered to in the DVI family is to use typecasts
  64. to specify explicit coercion, but such rigor requires automated
  65. tools which can check for compliance.
  66.  
  67. ANSI extensions to VAX VMS C have been reported by at least one
  68. site; we do not yet have the upgrade locally.  Microsoft C
  69. Version 5.0 is due out in October 1987, and should be similarly
  70. enhanced (it already had function prototypes declarations in
  71. Version 4.0).
  72.  
  73. Here now are the recent change log entries:
  74.  
  75. [28-Sep-87]     Updated all makefiles to include a generic target
  76.                 dvi$(PGM) and  an  extra compilation  flag  value
  77.                 XCFLAGS, so test versions can be constructed by a
  78.                 command like "make PGM=foo XCFLAGS=-g dvifoo".
  79.  
  80. [28-Sep-87]     {Thanks to Ian Young (ian@latlog.uucp)}
  81.                 At the  end  of  readgf.h,  newfont()  is  called
  82.                 before the loop which retrieves character metrics
  83.                 via chargf().  This  is incorrect for  HPJETPLUS,
  84.                 where the newfont() code in dvijep.c uses some of
  85.                 the metrics.   For the  other devices,  newfont()
  86.                 only sets values  in the  font character  tables.
  87.                 Therefore, move the newfont()  call to AFTER  the
  88.                 loop, so that the code reads in readgf.H:
  89.  
  90.     for (the_char = FIRSTPXLCHAR; the_char <= LASTPXLCHAR; the_char++)
  91.     {   /* Get remaining character metrics, and ignore error returns for now. */
  92.         tcharptr = &(fontptr->ch[the_char]);
  93.         if (tcharptr->fontrp >= 0L)
  94.             (void)chargf(the_char,(void(*)())NULL);
  95.     }
  96.  
  97. #if    (BBNBITGRAPH | HPJETPLUS | POSTSCRIPT | IMPRESS | CANON_A2)
  98.     (void)newfont();
  99. #endif
  100.  
  101. [28-Sep-87]     On Unix systems,  getlogin() returns  (char*)NULL
  102.                 if the process is not attached to a terminal,  in
  103.                 particular, if  the  process  is  attached  to  a
  104.                 pseudo-terminal (pty),  such as  a window  or  an
  105.                 editor shell  buffer.  The  way to  get the  real
  106.                 login name  in  these  circumstances  is  to  use
  107.                 cuserid((char*)NULL) in place of getlogin(),  and
  108.                 I have according made that change in dvialw.c and
  109.                 lptops.c,   and   added   appropriate    function
  110.                 declarations in gblprocs.h.
  111.  
  112.                 This  change  affects  only  text  output  in   a
  113.                 PostScript comment.   Both cuserid  and  getlogin
  114.                 are defined  in 4.2BSD  Unix,  AT&T SYS  V  Unix,
  115.                 HPUX, KCC  (version  4), and  IEEE  Posix  (which
  116.                 draft ANSI C follows).  PCC and V7 Unix had  only
  117.                 getlogin.  VAX  VMS  C  has  only  cuserid.   KCC
  118.                 (version 3), Microsoft C, Lattice C, and Wizard C
  119.                 have neither.
  120.  
  121. [23-Sep-87]     {Version 2.09 announcement}
  122.                 Testing  of  the  Free  Software  Foundation  gcc
  123.                 compiler has  uncovered two  bugs so  far in  the
  124.                 compiler (they  are  being fixed  rapidly).   gcc
  125.                 produces  code   for   both  VAX   and   Motorola
  126.                 architectures, and is being  used to develop  the
  127.                 GNU operating system.  The  testing also found  a
  128.                 serious  bug  in  my  code  which   unfortunately
  129.                 impacts most of the DVI  drivers, and can be  the
  130.                 cause of core dumps or other failures.
  131.  
  132.                 The  value  of  XSIZE  in  dvi*.c  is   currently
  133.                 computed as XDPI*XPSIZE,  that is, the number  of
  134.                 dots across the page.  Unfortunately, one or more
  135.                 local arrays are  later allocated  and used  with
  136.                 the assumption that  XSIZE is a  multiple of  the
  137.                 machine word size, HOST_WORD_SIZE, and in dvijet,
  138.                 it   was   assumed   to   be   a   multiple    of
  139.                 2*HOST_WORD_SIZE.
  140.  
  141.                 This bug was never caught on the DEC-20,  because
  142.                 there  stacks  grow   upward,  so   beyond-bounds
  143.                 references to stack  arrays may  just be  writing
  144.                 into unused memory.  However,  on the VAX,  Intel
  145.                 iAPX, and  Motorola  architectures,  stacks  grow
  146.                 downward, and such  references can  wipe out  the
  147.                 call history,  precipitating at  best an  address
  148.                 exception or illegal  instruction violation  when
  149.                 the return instruction  is executed.  This  would
  150.                 only  happen  if   text  was   set  against   the
  151.                 right-hand  side  of  the  page,  and  since  TeX
  152.                 documents usually produce wide margins, this  may
  153.                 be unlikely to happen.
  154.  
  155.                 To  avoid  complex  dimension  computations,  and
  156.                 preserve  uniformity  of  definition  among   the
  157.                 family, XSIZE is now  increased to a multiple  of
  158.                 2*HOST_WORD_SIZE  throughout.   The  fix  is   to
  159.                 change
  160.  
  161. #define  XSIZE          (XDPI*XPSIZE)   /* number of horizontal dots */
  162.  
  163.                 to
  164.  
  165. #define  XSIZE          (((XDPI*XPSIZE+2*HOST_WORD_SIZE-1)/\
  166.                                 (2*HOST_WORD_SIZE))*(2*HOST_WORD_SIZE))
  167.                                         /* number of horizontal dots; */
  168.                                         /* MUST BE multiple of */
  169.                                         /* 2*HOST_WORD_SIZE */
  170.  
  171.                 in all the dvi*.c files.  I view this bug fix  to
  172.                 be important enough to  warrant a version  number
  173.                 change, so  the family  is now  at version  2.09.
  174.  
  175.                 The following  Unix script  can be  used on  Unix
  176.                 systems to automate the patch:
  177.  
  178. #!/bin/csh
  179. foreach f (dvi*.c)
  180.         echo $f
  181.         mv $f $f-old
  182.         sed -f bugfix.sed <$f-old >$f
  183. end
  184.  
  185.                 Here is bugfix.sed:
  186. s|"2.08|"2.09|
  187. s|(XDPI\*XPSIZE)[       ]*/\* number of horizontal dots \*/|(((XDPI*XPSIZE+2*HOST_WORD_SIZE-1)/\\\
  188.                                 (2*HOST_WORD_SIZE))*(2*HOST_WORD_SIZE))\
  189.                                         /* number of horizontal dots; */\
  190.                                         /* MUST BE multiple of */\
  191.                                         /* 2*HOST_WORD_SIZE */|
  192.  
  193. [23-Sep-87]     In openfont.h,  nopen  is  incremented  when  the
  194.                 requested font  is  not  found  in  the  list  of
  195.                 currently open  files, but  the code  forgets  to
  196.                 decrement it  if  the  request  font  never  gets
  197.                 successfully opened, when can happen if the  font
  198.                 file cannot be found, and no substitution font is
  199.                 provided.  Change  the  code about  line  185  to
  200.                 decrement nopen on open  failure, so that it  now
  201.                 reads:
  202.  
  203.                 if (fontfp == (FILE*)NULL)
  204.                 {
  205.                     --nopen;            /* don't count this failed open */
  206.                     (void)sprintf(message,"Font file [%s [mag %d]] could not be \
  207.  
  208.  
  209. [18-Sep-87]     {Thanks to Mic Kaczmarczik (CC.KCACMARCZIK@A20.CC.UTEXAS.EDU)}
  210.                 When dvialw.ps  is modified  to select  LANDSCAPE
  211.                 mode instead of  NOTE (portrait),  the output  is
  212.                 positioned  incorrectly,  and  character  bitmaps
  213.                 look somewhat raggged.   The former is  due to  a
  214.                 missing translation  command, and  the latter  to
  215.                 tiny  non-zero  transformation  matrix   elements
  216.                 which introduce computed coordinates which are in
  217.                 error by  one  pixel.   I  have  also  taken  the
  218.                 liberty of  installing a  fix for  the fact  that
  219.                 NOTE  is  not  defined  on  non-Apple  PostScript
  220.                 printers.  It should  no longer  be necessary  to
  221.                 edit dvialw.ps for Texas Instruments, QMS, et  al
  222.                 PostScript printers.
  223.  
  224.                 There is one problem  with this change, and  that
  225.                 is that the SNAP call in the CharBuilder  routine
  226.                 must now be  executed for each  character set  on
  227.                 the page, so the output may prove to be  somewhat
  228.                 slower.  To check this, I downloaded dvialw.ps to
  229.                 our new Apple LaserWriter Plus, then executed
  230.  
  231.                 TeXdict begin
  232.                 usertime 10000 {0 0 SNAP pop pop} repeat usertime
  233.                 exch sub pstack
  234.  
  235.                 which results in a time  of 70844 msec for  10000
  236.                 calls,  or  an  extra  overhead  of  7  msec  per
  237.                 character.  Repeating  the  experiment  using  an
  238.                 empty procedure body gives  a loop overhead  time
  239.                 of 0.2 msec.  With an average of 3000  characters
  240.                 set per page,  this amounts to  21 sec per  page,
  241.                 which is  definitely  not  negligible.   You  may
  242.                 therefore wish to  leave the SNAP  call out of  a
  243.                 version  of  dvialw.ps  that  is  used  only  for
  244.                 portrait orientation output.
  245.  
  246.                 Similar timing  loops can  be used  to reveal  an
  247.                 average  execution  time  of   1  msec  for   any
  248.                 arithmetic    operation    (+-/*);     PostScript
  249.                 interpreters badly  need hardware  floating-point
  250.                 support!  There  is  a repeatable  difference  of
  251.                 about 10%  increase in  speed when  operands  are
  252.                 floating-point instead of integer values.  dvialw
  253.                 could be changed  to write floating-point  values
  254.                 instead of  integer  ones,  with  a  tradeoff  of
  255.                 slightly  increased  output   file  size  to   be
  256.                 balanced against slightly faster arithmetic.
  257.  
  258.                 At the same  time, I  increased XPSIZE  to 14  in
  259.                 dvialw.c so  that landscape  mode output  is  not
  260.                 clipped.  Future work should introduce a  general
  261.                 flexible solution to  the problem  of paper  size
  262.                 specification for all of the drivers.
  263.  
  264.                 Here is a  context difference  which records  the
  265.                 changes.  Additions are flagged with a "+" in the
  266.                 first column, and  changes with a  "!", with  the
  267.                 old code first, and the new second.
  268.  
  269. *** dvialw.ps-old       Wed Jul 29 14:35:41 1987
  270. --- dvialw.ps   Fri Sep 18 17:48:10 1987
  271. ***************
  272. *** 1,3 ****
  273. --- 1,10 ----
  274. + % <BEEBE.TEX.DVI>DVIALW.PS.17, 18-Sep-87 17:48:04, Edit by BEEBE
  275. + % Add test for note paper and if unknown, use letter paper instead.
  276. + % Non-Apple PostScript implementations do not know about note paper
  277. + % but its use on the Apple LaserWriter gains 92K of virtual memory
  278. + % <BEEBE.TEX.DVI>DVIALW.PS.16, 18-Sep-87 15:50:52, Edit by BEEBE
  279. + % Modify coordinate computations to remove round-off errors
  280. + % in landscape mode, and correct landscape page origin
  281.   % <BEEBE.TEX.DVI>DVIALW.PS.14, 22-Jun-87 09:55:05, Edit by BEEBE
  282.   % Add missing "0 900 translate Mtrx currentmatrix pop" to /LEGAL
  283.   % <BEEBE.TEX.DVI>DVIALW.PS.13,  7-Jan-87 17:38:51, Edit by BEEBE
  284. ***************
  285. *** 110,116 ****
  286.   /BOJ
  287.   {
  288.     72 Resolution div 72 Resolution div scale
  289. !   NOTE                                % default page format
  290.   } bdf
  291.  
  292.   % BOP -- beginning of page
  293. --- 117,126 ----
  294.   /BOJ
  295.   {
  296.     72 Resolution div 72 Resolution div scale
  297. !   userdict /note known
  298. !   {NOTE}                              % default page format for ALW
  299. !   {LETTER}                            % default page format for others
  300. !   ifelse
  301.   } bdf
  302.  
  303.   % BOP -- beginning of page
  304. ***************
  305. *** 146,151 ****
  306. --- 156,162 ----
  307.       ch-xoff neg                       ch-yoff ch-height sub
  308.       ch-width ch-xoff sub      ch-yoff
  309.       setcachedevice
  310. +     0 0 SNAP translate
  311.       ch-width ch-height true [ 1 0 0 -1 ch-xoff ch-yoff ]
  312.       {ch-image} imagemask
  313.     } if
  314. ***************
  315. *** 185,190 ****
  316. --- 196,202 ----
  317.     72 Resolution div dup scale
  318.     0 3300 translate
  319.     -90 rotate
  320. +   0 -750 translate
  321.     Mtrx currentmatrix pop
  322.   } bdf
  323.  
  324. ***************
  325. *** 271,276 ****
  326. --- 283,292 ----
  327.   % SF -- set new font at scale nnn (nnn = 1 normally; 2 gives double size chars)
  328.   % Usage -- nnn /fontname SF
  329.   /SF {findfont exch scalefont setfont} bdf() pop
  330. +
  331. + % SNAP -- convert coordinates to integer device coordinates and back again
  332. + % Usage -- xxx yyy SNAP (leave xxx' yyy' on stack)
  333. + /SNAP {transform 2 {floor 0.5 add exch} repeat itransform} bdf
  334.  
  335.   % T -- move absolute horizontally and show string, updating horizontal position
  336.   % to new endpt
  337.  
  338.  
  339. [08-Sep-87]
  340.                 In lptops.c, change
  341.                 OUTSTR(getlogin());
  342.                 to
  343.                 if (getlogin() != (char*)NULL)
  344.                     OUTSTR(getlogin());
  345.                 because getlogin()  can sometimes  return a  null
  346.                 pointer, instead of a null string.
  347.  
  348. [31-Aug-87]     {Thanks to HUXTABLE@UKANVAX.BITNET}
  349.                 In gblprocs.h in the  ANSI type declarations  for
  350.                 dvifile and  main, change  "char *[0]"  to  "char
  351.                 *[]".   The  "[0]"  is   an  odd  production   of
  352.                 Microsoft C which  was used to  prepare the  type
  353.                 declarations at compile time.  It sneaked through
  354.                 the editing (it is not needed for Microsoft C  to
  355.                 compile these).  VAX  VMS C  version 2.3-024  now
  356.                 supports ANSI function declaration prototypes;  I
  357.                 don't have it up yet.
  358. 28-Sep-87 19:15:06-MDT,17660;000000000000
  359. Date: Mon 28 Sep 87 19:15:06-MDT
  360. From: "Nelson H.F. Beebe" <Beebe@SCIENCE.UTAH.EDU>
  361. Subject: DVI driver family update #12
  362. To: "DVI mailing list": ;
  363. cc: BEEBE@SCIENCE.UTAH.EDU
  364. X-US-Mail: "Center for Scientific Computation, South Physics, University of Utah, Salt Lake City, UT 84112"
  365. X-Telephone: (801) 581-5254
  366. Message-ID: <12338345320.27.BEEBE@SCIENCE.UTAH.EDU>
  367.  
  368.                 DVI Driver Family Update #12
  369.                         [28-Sep-87]
  370.  
  371. This issue announces Version 2.09, some minor editorial changes,
  372. and fixes to three serious bugs, one of which affects only
  373. dvijep, another only dvialw, and the third, most of the
  374. dot-matrix printer drivers.  The fixes are extracted from the
  375. 00REVHST.TXT file, and I record below everything posted to it
  376. since Version 2.08 (20-Aug-87)
  377.  
  378. I am pleased to announce that the Free Software Foundation GNU
  379. Project C compiler, gcc, now successfully compiles the entire DVI
  380. driver family, both with and without optimization, on the Sun
  381. workstation.  gcc can be built to produce code for Motorola
  382. 68000, 68010, and 68020 CPU's, and for the DEC VAX architecture.
  383. I have installed version 1.11 here, and applied two bug fixes
  384. supplied by Richard Stallman to correct problems in gcc that
  385. showed up during the installation and testing of gcc on the DVI
  386. driver family.  This testing also revealed a bug in the driver
  387. family itself; the fix is documented below.
  388.  
  389. gcc currently runs with the host (Sun or VAX) C library, and
  390. consequently produces code which is calling-sequence compatible
  391. with the native Unix cc compilers.  Presumably a later release of
  392. gcc will include complete run-time libraries, since the goal of
  393. the GNU project is to produce a complete free-standing operating
  394. system that runs on multiple architectures, and is freely
  395. available in source form.
  396.  
  397. gcc's command-line switches are a superset of cc's.  An important
  398. virtue is that specification of the debug switch (-g) does not
  399. nullify the optimization switch (-O), which is one of the great
  400. flaws with the Sun compilers.  Optimization is likely to exhibit
  401. compiler bugs, and it is convenient to be able to track these
  402. down with a source-level debugger that can still find variables
  403. and line numbers, instead of an assembly-level debugger that only
  404. knows about machine addresses.  gcc also is current with the
  405. October 1986 draft of the ANSI C standard, including string
  406. concatenation ("foo" "bar" becomes "foobar"), preprocessor token
  407. squashing ('#define X(n) X##n' results in X(abc) expanding to
  408. Xabc), and function prototype declarations.
  409.  
  410. SRI has just released Version 4 of the TOPS-20 KCC compiler.
  411. Like gcc, this too conforms to the draft ANSI standard, and to
  412. the second edition of S. Harbison and G. Steele, ``C -- A
  413. Reference Manual'', Prentice-Hall (1987).  This version also
  414. finally implements ioctl.h and signal.h, and fills in
  415. miscellaneous other routines from the 4.2BSD Unix library that
  416. were missing in earlier KCC releases
  417.  
  418. The value of early availability of ANSI conformant compilers is
  419. significant, in that it permits more extensive testing of
  420. software portability, and also exposes the code to the more
  421. rigorous cross-checking available via function argument prototype
  422. declarations, a new feature introduced by the ANSI C committee.
  423. Function prototypes were actually borrowed from B. Stroustrup's
  424. C++ language, which is currently implemented as a preprocessor
  425. whose output is fed to the C compiler.
  426.  
  427. C's readiness to automatically coerce values in expressions,
  428. assignments, and function calls is sometimes convenient, but more
  429. often introduces subtle machine dependencies.  The approach I
  430. have rigorously adhered to in the DVI family is to use typecasts
  431. to specify explicit coercion, but such rigor requires automated
  432. tools which can check for compliance.
  433.  
  434. ANSI extensions to VAX VMS C have been reported by at least one
  435. site; we do not yet have the upgrade locally.  Microsoft C
  436. Version 5.0 is due out in October 1987, and should be similarly
  437. enhanced (it already had function prototypes declarations in
  438. Version 4.0).
  439.  
  440. Here now are the recent change log entries:
  441.  
  442. [28-Sep-87]     Updated all makefiles to include a generic target
  443.                 dvi$(PGM) and  an  extra compilation  flag  value
  444.                 XCFLAGS, so test versions can be constructed by a
  445.                 command like "make PGM=foo XCFLAGS=-g dvifoo".
  446.  
  447. [28-Sep-87]     {Thanks to Ian Young (ian@latlog.uucp)}
  448.                 At the  end  of  readgf.h,  newfont()  is  called
  449.                 before the loop which retrieves character metrics
  450.                 via chargf().  This  is incorrect for  HPJETPLUS,
  451.                 where the newfont() code in dvijep.c uses some of
  452.                 the metrics.   For the  other devices,  newfont()
  453.                 only sets values  in the  font character  tables.
  454.                 Therefore, move the newfont()  call to AFTER  the
  455.                 loop, so that the code reads in readgf.H:
  456.  
  457.     for (the_char = FIRSTPXLCHAR; the_char <= LASTPXLCHAR; the_char++)
  458.     {   /* Get remaining character metrics, and ignore error returns for now. */
  459.         tcharptr = &(fontptr->ch[the_char]);
  460.         if (tcharptr->fontrp >= 0L)
  461.             (void)chargf(the_char,(void(*)())NULL);
  462.     }
  463.  
  464. #if    (BBNBITGRAPH | HPJETPLUS | POSTSCRIPT | IMPRESS | CANON_A2)
  465.     (void)newfont();
  466. #endif
  467.  
  468. [28-Sep-87]     On Unix systems,  getlogin() returns  (char*)NULL
  469.                 if the process is not attached to a terminal,  in
  470.                 particular, if  the  process  is  attached  to  a
  471.                 pseudo-terminal (pty),  such as  a window  or  an
  472.                 editor shell  buffer.  The  way to  get the  real
  473.                 login name  in  these  circumstances  is  to  use
  474.                 cuserid((char*)NULL) in place of getlogin(),  and
  475.                 I have according made that change in dvialw.c and
  476.                 lptops.c,   and   added   appropriate    function
  477.                 declarations in gblprocs.h.
  478.  
  479.                 This  change  affects  only  text  output  in   a
  480.                 PostScript comment.   Both cuserid  and  getlogin
  481.                 are defined  in 4.2BSD  Unix,  AT&T SYS  V  Unix,
  482.                 HPUX, KCC  (version  4), and  IEEE  Posix  (which
  483.                 draft ANSI C follows).  PCC and V7 Unix had  only
  484.                 getlogin.  VAX  VMS  C  has  only  cuserid.   KCC
  485.                 (version 3), Microsoft C, Lattice C, and Wizard C
  486.                 have neither.
  487.  
  488. [23-Sep-87]     {Version 2.09 announcement}
  489.                 Testing  of  the  Free  Software  Foundation  gcc
  490.                 compiler has  uncovered two  bugs so  far in  the
  491.                 compiler (they  are  being fixed  rapidly).   gcc
  492.                 produces  code   for   both  VAX   and   Motorola
  493.                 architectures, and is being  used to develop  the
  494.                 GNU operating system.  The  testing also found  a
  495.                 serious  bug  in  my  code  which   unfortunately
  496.                 impacts most of the DVI  drivers, and can be  the
  497.                 cause of core dumps or other failures.
  498.  
  499.                 The  value  of  XSIZE  in  dvi*.c  is   currently
  500.                 computed as XDPI*XPSIZE,  that is, the number  of
  501.                 dots across the page.  Unfortunately, one or more
  502.                 local arrays are  later allocated  and used  with
  503.                 the assumption that  XSIZE is a  multiple of  the
  504.                 machine word size, HOST_WORD_SIZE, and in dvijet,
  505.                 it   was   assumed   to   be   a   multiple    of
  506.                 2*HOST_WORD_SIZE.
  507.  
  508.                 This bug was never caught on the DEC-20,  because
  509.                 there  stacks  grow   upward,  so   beyond-bounds
  510.                 references to stack  arrays may  just be  writing
  511.                 into unused memory.  However,  on the VAX,  Intel
  512.                 iAPX, and  Motorola  architectures,  stacks  grow
  513.                 downward, and such  references can  wipe out  the
  514.                 call history,  precipitating at  best an  address
  515.                 exception or illegal  instruction violation  when
  516.                 the return instruction  is executed.  This  would
  517.                 only  happen  if   text  was   set  against   the
  518.                 right-hand  side  of  the  page,  and  since  TeX
  519.                 documents usually produce wide margins, this  may
  520.                 be unlikely to happen.
  521.  
  522.                 To  avoid  complex  dimension  computations,  and
  523.                 preserve  uniformity  of  definition  among   the
  524.                 family, XSIZE is now  increased to a multiple  of
  525.                 2*HOST_WORD_SIZE  throughout.   The  fix  is   to
  526.                 change
  527.  
  528. #define  XSIZE          (XDPI*XPSIZE)   /* number of horizontal dots */
  529.  
  530.                 to
  531.  
  532. #define  XSIZE          (((XDPI*XPSIZE+2*HOST_WORD_SIZE-1)/\
  533.                                 (2*HOST_WORD_SIZE))*(2*HOST_WORD_SIZE))
  534.                                         /* number of horizontal dots; */
  535.                                         /* MUST BE multiple of */
  536.                                         /* 2*HOST_WORD_SIZE */
  537.  
  538.                 in all the dvi*.c files.  I view this bug fix  to
  539.                 be important enough to  warrant a version  number
  540.                 change, so  the family  is now  at version  2.09.
  541.  
  542.                 The following  Unix script  can be  used on  Unix
  543.                 systems to automate the patch:
  544.  
  545. #!/bin/csh
  546. foreach f (dvi*.c)
  547.         echo $f
  548.         mv $f $f-old
  549.         sed -f bugfix.sed <$f-old >$f
  550. end
  551.  
  552.                 Here is bugfix.sed:
  553. s|"2.08|"2.09|
  554. s|(XDPI\*XPSIZE)[       ]*/\* number of horizontal dots \*/|(((XDPI*XPSIZE+2*HOST_WORD_SIZE-1)/\\\
  555.                                 (2*HOST_WORD_SIZE))*(2*HOST_WORD_SIZE))\
  556.                                         /* number of horizontal dots; */\
  557.                                         /* MUST BE multiple of */\
  558.                                         /* 2*HOST_WORD_SIZE */|
  559.  
  560. [23-Sep-87]     In openfont.h,  nopen  is  incremented  when  the
  561.                 requested font  is  not  found  in  the  list  of
  562.                 currently open  files, but  the code  forgets  to
  563.                 decrement it  if  the  request  font  never  gets
  564.                 successfully opened, when can happen if the  font
  565.                 file cannot be found, and no substitution font is
  566.                 provided.  Change  the  code about  line  185  to
  567.                 decrement nopen on open  failure, so that it  now
  568.                 reads:
  569.  
  570.                 if (fontfp == (FILE*)NULL)
  571.                 {
  572.                     --nopen;            /* don't count this failed open */
  573.                     (void)sprintf(message,"Font file [%s [mag %d]] could not be \
  574.  
  575.  
  576. [18-Sep-87]     {Thanks to Mic Kaczmarczik (CC.KCACMARCZIK@A20.CC.UTEXAS.EDU)}
  577.                 When dvialw.ps  is modified  to select  LANDSCAPE
  578.                 mode instead of  NOTE (portrait),  the output  is
  579.                 positioned  incorrectly,  and  character  bitmaps
  580.                 look somewhat raggged.   The former is  due to  a
  581.                 missing translation  command, and  the latter  to
  582.                 tiny  non-zero  transformation  matrix   elements
  583.                 which introduce computed coordinates which are in
  584.                 error by  one  pixel.   I  have  also  taken  the
  585.                 liberty of  installing a  fix for  the fact  that
  586.                 NOTE  is  not  defined  on  non-Apple  PostScript
  587.                 printers.  It should  no longer  be necessary  to
  588.                 edit dvialw.ps for Texas Instruments, QMS, et  al
  589.                 PostScript printers.
  590.  
  591.                 There is one problem  with this change, and  that
  592.                 is that the SNAP call in the CharBuilder  routine
  593.                 must now be  executed for each  character set  on
  594.                 the page, so the output may prove to be  somewhat
  595.                 slower.  To check this, I downloaded dvialw.ps to
  596.                 our new Apple LaserWriter Plus, then executed
  597.  
  598.                 TeXdict begin
  599.                 usertime 10000 {0 0 SNAP pop pop} repeat usertime
  600.                 exch sub pstack
  601.  
  602.                 which results in a time  of 70844 msec for  10000
  603.                 calls,  or  an  extra  overhead  of  7  msec  per
  604.                 character.  Repeating  the  experiment  using  an
  605.                 empty procedure body gives  a loop overhead  time
  606.                 of 0.2 msec.  With an average of 3000  characters
  607.                 set per page,  this amounts to  21 sec per  page,
  608.                 which is  definitely  not  negligible.   You  may
  609.                 therefore wish to  leave the SNAP  call out of  a
  610.                 version  of  dvialw.ps  that  is  used  only  for
  611.                 portrait orientation output.
  612.  
  613.                 Similar timing  loops can  be used  to reveal  an
  614.                 average  execution  time  of   1  msec  for   any
  615.                 arithmetic    operation    (+-/*);     PostScript
  616.                 interpreters badly  need hardware  floating-point
  617.                 support!  There  is  a repeatable  difference  of
  618.                 about 10%  increase in  speed when  operands  are
  619.                 floating-point instead of integer values.  dvialw
  620.                 could be changed  to write floating-point  values
  621.                 instead of  integer  ones,  with  a  tradeoff  of
  622.                 slightly  increased  output   file  size  to   be
  623.                 balanced against slightly faster arithmetic.
  624.  
  625.                 At the same  time, I  increased XPSIZE  to 14  in
  626.                 dvialw.c so  that landscape  mode output  is  not
  627.                 clipped.  Future work should introduce a  general
  628.                 flexible solution to  the problem  of paper  size
  629.                 specification for all of the drivers.
  630.  
  631.                 Here is a  context difference  which records  the
  632.                 changes.  Additions are flagged with a "+" in the
  633.                 first column, and  changes with a  "!", with  the
  634.                 old code first, and the new second.
  635.  
  636. *** dvialw.ps-old       Wed Jul 29 14:35:41 1987
  637. --- dvialw.ps   Fri Sep 18 17:48:10 1987
  638. ***************
  639. *** 1,3 ****
  640. --- 1,10 ----
  641. + % <BEEBE.TEX.DVI>DVIALW.PS.17, 18-Sep-87 17:48:04, Edit by BEEBE
  642. + % Add test for note paper and if unknown, use letter paper instead.
  643. + % Non-Apple PostScript implementations do not know about note paper
  644. + % but its use on the Apple LaserWriter gains 92K of virtual memory
  645. + % <BEEBE.TEX.DVI>DVIALW.PS.16, 18-Sep-87 15:50:52, Edit by BEEBE
  646. + % Modify coordinate computations to remove round-off errors
  647. + % in landscape mode, and correct landscape page origin
  648.   % <BEEBE.TEX.DVI>DVIALW.PS.14, 22-Jun-87 09:55:05, Edit by BEEBE
  649.   % Add missing "0 900 translate Mtrx currentmatrix pop" to /LEGAL
  650.   % <BEEBE.TEX.DVI>DVIALW.PS.13,  7-Jan-87 17:38:51, Edit by BEEBE
  651. ***************
  652. *** 110,116 ****
  653.   /BOJ
  654.   {
  655.     72 Resolution div 72 Resolution div scale
  656. !   NOTE                                % default page format
  657.   } bdf
  658.  
  659.   % BOP -- beginning of page
  660. --- 117,126 ----
  661.   /BOJ
  662.   {
  663.     72 Resolution div 72 Resolution div scale
  664. !   userdict /note known
  665. !   {NOTE}                              % default page format for ALW
  666. !   {LETTER}                            % default page format for others
  667. !   ifelse
  668.   } bdf
  669.  
  670.   % BOP -- beginning of page
  671. ***************
  672. *** 146,151 ****
  673. --- 156,162 ----
  674.       ch-xoff neg                       ch-yoff ch-height sub
  675.       ch-width ch-xoff sub      ch-yoff
  676.       setcachedevice
  677. +     0 0 SNAP translate
  678.       ch-width ch-height true [ 1 0 0 -1 ch-xoff ch-yoff ]
  679.       {ch-image} imagemask
  680.     } if
  681. ***************
  682. *** 185,190 ****
  683. --- 196,202 ----
  684.     72 Resolution div dup scale
  685.     0 3300 translate
  686.     -90 rotate
  687. +   0 -750 translate
  688.     Mtrx currentmatrix pop
  689.   } bdf
  690.  
  691. ***************
  692. *** 271,276 ****
  693. --- 283,292 ----
  694.   % SF -- set new font at scale nnn (nnn = 1 normally; 2 gives double size chars)
  695.   % Usage -- nnn /fontname SF
  696.   /SF {findfont exch scalefont setfont} bdf() pop
  697. +
  698. + % SNAP -- convert coordinates to integer device coordinates and back again
  699. + % Usage -- xxx yyy SNAP (leave xxx' yyy' on stack)
  700. + /SNAP {transform 2 {floor 0.5 add exch} repeat itransform} bdf
  701.  
  702.   % T -- move absolute horizontally and show string, updating horizontal position
  703.   % to new endpt
  704.  
  705.  
  706. [08-Sep-87]
  707.                 In lptops.c, change
  708.                 OUTSTR(getlogin());
  709.                 to
  710.                 if (getlogin() != (char*)NULL)
  711.                     OUTSTR(getlogin());
  712.                 because getlogin()  can sometimes  return a  null
  713.                 pointer, instead of a null string.
  714.  
  715. [31-Aug-87]     {Thanks to HUXTABLE@UKANVAX.BITNET}
  716.                 In gblprocs.h in the  ANSI type declarations  for
  717.                 dvifile and  main, change  "char *[0]"  to  "char
  718.                 *[]".   The  "[0]"  is   an  odd  production   of
  719.                 Microsoft C which  was used to  prepare the  type
  720.                 declarations at compile time.  It sneaked through
  721.                 the editing (it is not needed for Microsoft C  to
  722.                 compile these).  VAX  VMS C  version 2.3-024  now
  723.                 supports ANSI function declaration prototypes;  I
  724.                 don't have it up yet.
  725. -------
  726.